<template>
    <van-cell-group>
        <van-cell>
            <div class="project">
                <div class="project-setting" @click="$emit('showAppManage')">
                    <van-icon name="setting-o" class="icon"/>
                </div>
                <van-row>
                    <van-col v-for="app in dataSource" :key="app.id"
                             span="6"
                             @click="$emit('showAppTaskList', app.id)">
                        <van-icon name="chat-o" class="icon"></van-icon>
                        <br>{{app.groupName}}
                    </van-col>
                </van-row>
            </div>
        </van-cell>
    </van-cell-group>
</template>

<script>

    export default {
        name: 'appList',
        props: {
            refresh: Boolean,
        },
        data() {
            return {
                dataSource: [],
                url: {
                    list: '/api/eform/manage/actAppGroup/getCustomAppList?isMobile=true',
                }
            }
        },
        methods: {
            loadData() {
                this.$mask.open();
                this.$http.get(this.url.list).then((res) => {
                    this.dataSource = res.result.customAppList;
                }).catch((err) => {
                    this.$notify({type: 'warning', message: '请求失败: ' + err, duration: 2000,});
                }).finally(() => {
                    this.$mask.close();
                });
            }
        },
        watch: {
            refresh: {
                handler(value) {
                    if (!value) {
                        this.loadData();
                    }
                },
                immediate: true
            }
        }
    }
</script>
